import java.util.*;
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();

        sc.nextLine();
        String s = sc.nextLine();



        while (m-- > 0) {
            int a = sc.nextInt();


            if (a == 1) {
                sc.nextLine();
                String st1 = sc.nextLine();


                s = s.replace(st1, sc.nextLine());
//                System.out.println(s);



            } else if (a == 2) {
                StringBuffer ret = new StringBuffer();
                String[] ss = s.split(" ");
                int b = Integer.parseInt(ss[0]);
                ret.append(b);
                ret.append(" ");
                for (int i = 1; i < ss.length; i++) {
                    int a1 = b;
                    b = Integer.parseInt(ss[i]);
                    int num = (a1 + b) % 2;
                    if (num == 0) {
                        ret.append((a1 + b) / 2);
                        ret.append(" ");
                    }

                    ret.append(b);
                    ret.append(" ");

                }


                ret.deleteCharAt(ret.length() - 1);
                s = ret.toString();

            } else {
                int l = sc.nextInt() ;
                int r = sc.nextInt() ;


                StringBuffer ret = new StringBuffer();
                String[] ss = s.split(" ");

                for (int i = 0; i < l; i++) {
                    int b = Integer.parseInt(ss[i]);

                    ret.append(b);
                    ret.append(" ");
                }


                for (int i = r; i >= l; i--) {
                    int b = Integer.parseInt(ss[i]);
                    ret.append(b);
                    ret.append(" ");
                }


                for (int i = r + 1; i < ss.length; i++) {
                    int b = Integer.parseInt(ss[i]);
                    ret.append(b);
                    ret.append(" ");

                }

                ret.deleteCharAt(ret.length() - 1);
                s = ret.toString();


            }



        }
        System.out.println(s);
    }
}